<%-- 
    Document   : addAbilities
    Created on : 24.11.2012, 10:29:51
    Author     : Siliarus
--%>

<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<fmt:bundle basename="StripesResources" /> 
<fmt:message key='admin.abilityManage' var="title"/>
<s:layout-render name="adminlayout.jsp" nadpis="${title}" >
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" var="actionBean"/>
        <center>
            <c:choose>
                <c:when test="${fn:length(actionBean.abilities) == 0}">
                    <div><font style="color: red;" ><fmt:message key="admin.ghostnoabilities"/></font></div><br /><br />
                </c:when>
                <c:otherwise>
                    <table class="zakladni" style="width:fit-content">
                        <tr>
                            <th><fmt:message key="admin.abilityName"/></th>
                            <th><fmt:message key="admin.abilityDescription"/></th>
                            <th><fmt:message key="admin.abilityLevel"/></th>
                            <th><fmt:message key="admin.abilityType"/></th>
                            <th><fmt:message key="admin.abilityDamage"/></th>
                            <th><fmt:message key="admin.abilityDelete"/></th>
                        </tr>
                        <c:forEach items="${actionBean.abilities}" var="ability">
                            <tr>                 
                                <td><c:out value="${ability.name}"/></td>
                                <td><c:out value="${ability.description}"/></td>
                                <td><c:out value="${ability.abilityLevel}"/></td>
                                <td><c:out value="${ability.abilityType}"/></td>
                                <td><c:out value="${ability.damage}"/></td>
                                <td><s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="deleteAbility">
                                        <s:param name="ability.id" value="${ability.id}"/>
                                        <s:param name="ghost.id" value="${actionBean.ghost.id}"/>
                                        <fmt:message key="admin.deleteAbFromGhost"/></s:link>
                                    </td>
                                </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>

            <s:form style="width:400px" beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean">
                <s:hidden name="ghost.id"/>
                <br /><fieldset><legend><fmt:message key="admin.selectAbility"/></legend>
                    <c:choose>
                        <c:when test="${fn:length(actionBean.availableAbilities) == 0}">
                            <br /><div><font style="color: red;" ><fmt:message key="menu.noabilities"/></div>
                            <s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="adminAbilities"><fmt:message key="admin.newAbility"/></s:link><br /><br />
                        </c:when>
                        <c:otherwise>
                            <c:set var="list" value="${actionBean.availableAbilities}"/> 
                            <s:select name="selectedAbility">  
                                <s:options-collection collection="${list}" label="name" value="id"/> 
                            </s:select>
                            <s:submit name="addAbilityToGhost"><fmt:message key="menu.ok"/></s:submit>

                        </c:otherwise>
                    </c:choose>
                </fieldset>
            </s:form>
                    <br />
            <s:link beanclass="cz.muni.fi.pa165.hauntedhouses.web.AdminGhostsActionBean" event="storno"><fmt:message key="menu.back"/></s:link>
        </center>
    </s:layout-component>
</s:layout-render>

